package com.teen9g.infoplatformserver.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.teen9g.dto.NoticePageQueryDTO;
import com.teen9g.entity.Notice;
import com.teen9g.infoplatformserver.mapper.NoticeMapper;
import com.teen9g.infoplatformserver.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeServiceImpl implements NoticeService {

    @Autowired
    private NoticeMapper noticeMapper;

    @Override
    public PageInfo<Notice> pageQuery(NoticePageQueryDTO noticePageQueryDTO) {
        PageHelper.startPage(noticePageQueryDTO.getPageNum(), noticePageQueryDTO.getPageSize());
        String noticeInput = noticePageQueryDTO.getNoticeInput();
        List<Notice> list = noticeMapper.pageQuery(noticeInput);
        return new PageInfo<>(list);
    }

    @Override
    public Notice getById(Integer id) {
        return noticeMapper.selectById(id);
    }
}
